﻿using ESRI.ArcGIS.Controls;
using ESRI.ArcGIS.SystemUI;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace GISDeveloping_test1_1_
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
            ZoomInTool zoomInTool = new ZoomInTool(axMapControl1);
            ZoomOutTool zoomOutTool = new ZoomOutTool(axMapControl1);

            // 添加ZoomInTool到工具栏
            zoomInTool.OnCreate(axMapControl1.Object);
            axToolbarControl1.AddItem(zoomInTool, -1, -1, false, 0, esriCommandStyles.esriCommandStyleIconAndText);

            // 添加ZoomOutTool到工具栏
            ICommand zoomOutCommand = (ICommand)(zoomOutTool as ITool);//待定，需确认Command与Tool
            zoomOutTool.OnCreate(axMapControl1.Object);
            axToolbarControl1.AddItem(zoomOutTool, -1, -1, false, 0, esriCommandStyles.esriCommandStyleIconAndText);
        }

        private void axToolbarControl1_OnItemClick(object sender, ESRI.ArcGIS.Controls.IToolbarControlEvents_OnItemClickEvent e)
        {
            ITool clickedTool = axToolbarControl1.GetItem(e.index).Command as ITool;
            if (clickedTool is ZoomInTool)
            {
                axMapControl1.CurrentTool = new ControlsMapZoomInToolClass();
            }
            else if (clickedTool is ZoomOutTool)
            {
                axMapControl1.CurrentTool = new ControlsMapZoomOutToolClass();
            }
        }
    }
}
